package com.hex.ds.hdrs.period.task.dto.depend;

import cn.hutool.core.util.StrUtil;
import com.hex.ds.hdrs.common.constant.TaskStatusCode;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@Data
@Accessors(chain = true)
public class DependPeriodTaskDto {

    private String pkId;

    private String jobCode;

    private String taskCode;

    private String taskName;

    private String taskStatus;

    private String taskType;

    private String dependTask;

    private String dependJob;

    private String bizDate;

    public String getTaskStatus() {
        return "periodTask".equals(taskType) ? TaskStatusCode.getStatus(taskStatus) : taskStatus;
    }

    public String getNodeName() {
        return taskCode + taskName + "(" + getTaskStatus() + ")";
    }

    public List<String> getDependTaskList() {
        if (StrUtil.isNotBlank(dependTask)) {
            List<String> list = new ArrayList<>();
            Collections.addAll(list, StrUtil.split(dependTask, ","));
            return list;
        }
        return new ArrayList<>();
    }

    public List<String> getDependJobList() {
        if (StrUtil.isNotBlank(dependJob)) {
            List<String> list = new ArrayList<>();
            Collections.addAll(list, StrUtil.split(dependJob, ","));
            return list;
        }
        return new ArrayList<>();
    }
}
